import random

# 读取原始文件
input_file = "train.txt"  # 你的txt文件路径
output_file = "train_data.txt"  # 输出的新文件路径

with open(input_file, "r", encoding="utf-8") as infile, open(output_file, "w", encoding="utf-8") as outfile:
    for line in infile:
        parts = line.strip().split("\t")  # 按制表符分割
        if parts:  # 确保行不为空
            parts[0] = str(random.randint(0, 9))  # 生成0-9的随机数替换label
            outfile.write("\t".join(parts) + "\n")

print("处理完成，修改后的数据已保存到", output_file)
